//
//  VRScrollCollectionViewController.m
//  MyDemos
//
//  Created by Veer on 16/8/15.
//  Copyright © 2016年 veer. All rights reserved.
//

#import "VRScrollCollectionViewController.h"

#import "VRCollectionViewCell.h"
#import "VRFlowLayout.h"


static NSString *cellID = @"collectionCell";


@interface VRScrollCollectionViewController() <UICollectionViewDelegate, UICollectionViewDataSource>



@end

@implementation VRScrollCollectionViewController

- (void)viewDidLoad
{
    [super viewDidLoad];
    
    self.view.backgroundColor = [UIColor whiteColor];
    self.automaticallyAdjustsScrollViewInsets = NO;
    
    VRFlowLayout *flowLayout = [[VRFlowLayout alloc] init];
    flowLayout.itemSize = CGSizeMake(180, 200);
    
    UICollectionView *collectionView = [[UICollectionView alloc] initWithFrame:CGRectMake(0, 80, Screen_width, 200) collectionViewLayout:flowLayout];
    collectionView.backgroundColor = [UIColor clearColor];
    collectionView.delegate = self;
    collectionView.dataSource = self;
    collectionView.showsHorizontalScrollIndicator = NO;
    [self.view addSubview:collectionView];
    
    [collectionView registerClass:[VRCollectionViewCell class] forCellWithReuseIdentifier:cellID];

}


#pragma mark - 代理方法

- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
{
    return 10;
}


- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{

    VRCollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:cellID forIndexPath:indexPath];
    cell.imageName = [NSString stringWithFormat:@"%zd", indexPath.row % 5 + 1];
    
    return cell;
}


@end
